mod config;
mod import;
mod export;
mod page;
pub use config::*;
pub use import::*;

pub async fn init_config() -> anyhow::Result<()> {
    config::init_excel_rept_config().await?;
    config::init_excel_import_config().await?;
    Ok(())
}
#[cfg(test)]
mod tests {
    use shq_common::prelude::init_app_config;
    use tracing_subscriber::{filter::LevelFilter, prelude::*};
    use super::*;
    async fn init()->anyhow::Result<()> {
        dotenv::dotenv().ok();
        let stdout_log = tracing_subscriber::fmt::layer().pretty();
        tracing_subscriber::registry()
            .with(LevelFilter::INFO)
            .with(stdout_log)
            .init();
        init_app_config().await?;
        init_config().await?;
        Ok(())
    }
    #[tokio::test]
    async fn test_yj_gf01() {
        init().await.unwrap();
        let file_path = "/Users/zhaoqiang/Downloads/GF0101_241--境内汇总数据-1月-人民币.xls";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
    #[tokio::test]
    async fn test_zhkpi_shfh() {
        init().await.unwrap();
        let file_path = "/Users/zhaoqiang/Downloads/2025年一季度KPI综合打分-上海分行.xlsx";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
    #[tokio::test]
    async fn test_zhzj_shfh() {
        init().await.unwrap();
        let file_path = "/Users/zhaoqiang/Downloads/表1：202503奖励明细表-上海分行（含自贸）.xlsx";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
    #[tokio::test]
    async fn test_gfh_lrzb() {
        init().await.unwrap();
        let file_path = "/Users/zhaoqiang/Downloads/OA--2025利润指标完成计算表-20250131-以此为准.xlsx";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
    #[tokio::test]
    async fn test_gfn_jydtpm() {
        init().await.unwrap();
        let file_path = "/Users/zhaoqiang/Downloads/给赵工的数据/动态排名/2025年1月份月度经营动态排名.xlsx";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
        let file_path = "/Users/zhaoqiang/Downloads/给赵工的数据/动态排名/2024年12月份月度经营动态排名.xlsx";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
    #[tokio::test]
    async fn test_gfn_lcqk() {
        init().await.unwrap();
        let file_path = "/Users/zhaoqiang/Downloads/给赵工的数据/利差/2025年1月末各条线、各分行利差情况.xlsx";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
    #[tokio::test]
    async fn test_thy_cdk_pm() {
        init().await.unwrap();
        let file_path = "/Users/zhaoqiang/Downloads/给赵工的数据/同业排名/上海地区2025年1月本外币存贷款排名表（剔除非银）.xls";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
    #[tokio::test]
    async fn test_thy_dklv() {
        init().await.unwrap();
        let file_path = "/Users/zhaoqiang/Downloads/计财报表导入/分区域企业贷款利率分析2025.01-三家行.xlsx";
        let result = import_by_excel("thy_dklv", file_path, &[]).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
    #[tokio::test]
    async fn test_ybsfz_pmql() {
        init().await.unwrap();
        let file_path = "/Users/wj/Downloads/经营单位一把手、副职业绩排名/2025年5月各经营单位一把手、副职排名表.xlsx";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
     #[tokio::test]
    async fn test_shfh_ztzbqk() {
        init().await.unwrap();
        let file_path = "/Users/wj/Downloads/分行整体指标情况/2025年月度分行整体指标情况.xlsx";
        let result = import_excel_by_conf(file_path).await;
        if let Err(e) = &result {
            println!("{:?}", e);
        }
        assert!(result.is_ok());
    }
}
